<style lang="scss" scoped>
html {
  height: 100%;
}
body {
  height: 100%;
  margin: 0px;
  padding: 0px;
}
.activityShow {
  height: 100%;
  padding-top: 3rem;
  .my_tuan {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3rem;
    z-index: 2;
    // background: -webkit-linear-gradient(top, #fd8701, #fd8701);
    line-height: 3rem;
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #fff;
    .icon {
      position: absolute;
      top: 50%;
      left: 10px;
      transform: translateY(-50%);
    }
  }
  #container {
    height: 100%;
  }
}
</style>
<template>
  <div class="activityShow">

  </div>
</template>

<script>
import {
  Button,
  Toast,
  Tab,
  Tabs,
  Icon,
  Dialog,
  Popup,
  Field,
  RadioGroup,
  Radio,
  Image as VanImage,
} from "vant";
export default {
  name: "activityShow",
  components: {
    [Tab.name]: Tab,
    [Tabs.name]: Tabs,
    [Button.name]: Button,
    [Icon.name]: Icon,
    [Dialog.name]: Dialog,
    [Popup.name]: Popup,
    [Field.name]: Field,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [VanImage.name]: VanImage,
  },
  data() {
    return {
      // key: "ECABZ-ZR2CV-CUSPW-UQQGG-CCV3J-ZTBZR",
      theme_color: "#ed2d2d",
      adress: "",
      name: '',
      lat: 0,
      lng: 0,
    };
  },
  created() {
    this.adress = this.$route.query.adress;
    // this.btn_color = this.$route.query.btn_color
    // console.log(this.adress, 232323);
  },
  computed: {},
  mounted() {
    this.shareInit();
    this.getLal(this.adress,(res => {
      this.openLocation(res.detail.addressComponents.street,res.detail.location.lat,res.detail.location.lng)
    }))
  },
  methods: {
    iconClick() {
      this.$router.go(-1);
    },
    shareInit() {
      const _this = this;
      const url = location.href.split("#")[0];
      let params = {
        url: url,
      };
      _this.$request.configJssdk(params).then((res) => {
        console.log(res, "-------------res");
        wx.config({
          debug: false, // 是否开启调试模式
          appId: res.data.appId, //appid
          timestamp: res.data.timestamp, // 时间戳
          nonceStr: res.data.nonceStr, // 随机字符串
          signature: res.data.signature, // 签名
          jsApiList: ["openLocation", "getLocation"], // 需要使用的JS接口列表
        });
      });
    },
    getLal(address,cb) {
      var geocoder = new qq.maps.Geocoder();
      geocoder.getLocation(address);
      geocoder.setComplete(function(res) {
          cb(res)
       });
      geocoder.setError(function(err) {
          cb(res)
      });
    },


    openLocation(name, lat, lng) {
      wx.openLocation({
      latitude: lat,
      longitude: lng,
      name: name,
      address: this.adress,
      scale: 14,
      infoUrl: 'http://weixin.qq.com'
    });
    },
    getLocation() {
      wx.getLocation({
      success: function (res) {
        alert(JSON.stringify(res));
      },
      cancel: function (res) {
        alert('用户拒绝授权获取地理位置');
      }
    });
    }
  },
};
</script>